<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Backbone.js Todos</title>
    <link rel="stylesheet" href="todos.css" />
</head>
<body>
<div id="todoapp">
    <header>
        <h1>
            Todos</h1>
        <input id="new-todo" type="text" placeholder="What needs to be done?">
    </header>
    <section id="main">
        <input id="toggle-all" type="checkbox">
        <label for="toggle-all">
            Mark all as complete</label>
        <ul id="todo-list">
        </ul>
    </section>
</div>
<script src="js/json2.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/underscore.js" type="text/javascript"></script>
<script src="js/backbone.js" type="text/javascript"></script>
<script src="js/backbone.localStorage.js" type="text/javascript"></script>
<script src="js/todos.js" type="text/javascript"></script>
</body>
</html>



<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../js/jquery-1.11.3.js"></script>
    <script src="../js/underscore.js"></script>
    <script src="../js/backbone.js"></script>
</head>
<body>
<button>alert</button>
<script>
    var object = {};

    _.extend(object, Backbone.Events);

    object.on("alert", function(msg) {
        alert("Triggered " + msg);
    });

    $('button').click(function(){
        object.trigger("alert", "an event");
    })

    var User = Backbone.Model.extend({
        validate: function (attr) {
            if (!attr.name || attr.name.length < 3) {
                return '名称长度过短';
            }
        }
    });
    var user  = new User();

    user.bind('error', function (model, error) {
        //错误处理
        console.log('error');
    });

    user.set({ name: '0' });
    //给特定集合添加一个错误处理程序
    user.set({ name: '0' }, { error: function (model, error) { } });

</script>
</body>
</html>